<?php
session_start();
if (isset($_SESSION["username"])) {
?>
    <?php require_once('common/header.php'); ?>
    <!--页面主要内容-->
    <main class="lyear-layout-content">
        <div class="container-fluid">

            <?php
            include_once("../untils/conn.php");
            $id = $_GET['id'];
            $data = mysqli_query($con, "select * from oder where id=" . $id);
            $rows = mysqli_fetch_row($data);
            ?>
            <div class="card">
                <div class="card-header bg-primary">
                    <h4>处理订单状态</h4>
                </div>
                <div class="card-body">
                    <form class="form-horizontal" action="controller/doUpdatesta.php" method="POST">
                        
                     <div class="form-group">
                            <label class="col-xs-12">订单处理状态：</label>
                            <div class="col-xs-12">
                                <select name="status" id="status" class="form-control">
                                    <option value="">请选择状态</option>
                                    <?php
                                    include_once("../untils/conn.php");
                                    mysqli_query($con, "set names utf8");
                                    // 获取订单状态
                                    $status_sql = "SELECT DISTINCT `status` FROM `order`";
                                    $status_data = mysqli_query($con, $status_sql);
                    
                                    $statuses = [
                                        ['id' => 0, 'text' => '未处理'],
                                        ['id' => 1, 'text' => '已下单'],
                                        ['id' => 2, 'text' => '已发货'],
                                        ['id' => 3, 'text' => '已完成'],
                                        ['id' => 4, 'text' => '开卡失败']
                                    ];
                    
                                    foreach($statuses as $status) {
                                        $selected = '';
                                        if ($status['id'] == $rows[9]) {
                                            $selected = 'selected';
                                        }
                                        echo "<option value='{$status['id']}' {$selected}>{$status['text']}</option>";
                                    }
                                    ?>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-xs-12">号码状态：</label>
                            <div class="col-xs-12">
                                <select name="card_sta" id="status" class="form-control">
                                    <option value="">请选择状态</option>
                                    <?php
                                    include_once("../untils/conn.php");
                                    mysqli_query($con, "set names utf8");
                                    // 获取订单状态
                                    $card_sta_sql = "SELECT DISTINCT `card_sta` FROM `order`";
                                    $status_data = mysqli_query($con, $card_sta_sql);
                    
                                    $statuses = [
                                        ['id' => 0, 'text' => '未激活'],
                                        ['id' => 1, 'text' => '已激活'],
                                       
                                    ];
                    
                                    foreach($statuses as $status) {
                                        $selected = '';
                                        if ($status['id'] == $rows[9]) {
                                            $selected = 'selected';
                                        }
                                        echo "<option value='{$status['id']}' {$selected}>{$status['text']}</option>";
                                    }
                                    ?>
                                </select>
                            </div>
                        </div>

                        <div class="form-group">
                            <label for="title" class="col-xs-12">备注：</label>
                            <div class="col-xs-12">
                                <input type="text" class="form-control" name="beizhu" placeholder="请输入备注" value="<?php echo $rows[10] ?>" required>
                            </div>
                        </div>
                        
                        <div class="form-group">
                            <input type="hidden" name="id" value="<?php echo $id ?>">
                            <input type="hidden" name="oderid" value="<?php echo $rows[11] ?>">
                            <div class="offset-2 col-xs-12">
                                <button class="btn btn-success" type="submit" value="添加">确认修改</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
        </div>
        </div>
        </div>
        </div>


        </div>
    </main>
    <!--End 页面主要内容-->
    <?php require_once('common/footer.php'); ?>
<?php
} else {
    echo "<script>alert('您尚未登录，没有权限访问该页面');location.href='login.php';</script>";
}
